<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<form action="">
	<p>用户名:<input id="inp" type="text" onfocus="f1()" onblur="f2()" /></p>
	<p>邮箱:<input id="arr" type="text" onfocus="f3()" onblur="f4()" /></p>
	<p>密码:<input id="intr" type="text" onfocus="f5()" onblur="f6()" /></p>
	</form>
</body>
	<script type="text/javascript">
		var inp = document.getElementsByTagName('input');
		function f1(){
			inp[0].style.background = 'lime';
		}
		function f2(){
			inp[0].style.background = 'aqua';
		}

		var arr = document.getElementById('arr');
		function f3(){
			inp[1].style.background = 'orange';
		}
		function f4(){
			inp[1].style.background = 'pink';
		}

		var intr = document.getElementById('intr');
		function f5(){
			inp[2].style.background = 'red';
		}
		function f6(){
			inp[2].style.background = 'green';
		}
	</script>
</html>